package com.zzyl.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.zzyl.entity.Bed;
import com.zzyl.mapper.BedMapper;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedServiceImpl implements BedService {

    @Autowired
    private BedMapper bedMapper;

    @Override
    public List<BedVo> getBedsByRoomId(Long roomId) {
        return bedMapper.getBedsByRoomId(roomId);
    }

    /**
     * 创建床位
     * @param bed
     * @return
     */
    @Override
    public void createBed(Bed bed) {
        bedMapper.insertBed(bed);
    }

    /**
     * 根据id查询床位
     * @param id
     * @return
     */
    @Override
    public BedVo readBedById(Long id) {
        BedVo bedVo = bedMapper.selectById(id);
        return bedVo;
    }

    /**
     * 更新床位
     * @param bed
     * @return
     */
    @Override
    public void updateBedById(Bed bed) {
        bedMapper.updateById(bed);
    }

    /**
     * 根据id删除床位
     * @param id
     * @return
     */
    @Override
    public void deleteBedById(Long id) {
        bedMapper.deleteById(id);
    }
}

